#ifndef MUTEXQUEUE_H
#define MUTEXQUEUE_H

#pragma once
#include <mutex>
#include <queue>
#include <condition_variable>

// #include <contion_vari>
template<class T>
class MutexQueue
{
public:
    MutexQueue() = default;
    ~MutexQueue() = default;
    T pop() {
        std::unique_lock<std::mutex> lock(mtx_);
        while(que_.empty()) {
            cond_.wait(lock);
        }
        T front = que_.front();
        que_.pop();
        return front;
    }
    void push(const T& data) {
        std::unique_lock<std::mutex> lock(mtx_);
        que_.push(data);
        cond_.notify_one();
    }
private:
    std::queue<T> que_;
    std::condition_variable cond_;
    std::mutex mtx_;

};

#endif